﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="mtaarinimed_paring", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(MtaarinimedParing))]
    public class MtaarinimedParingSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMtaarinimedParing clazz;
        
        public MtaarinimedParingSerializer(IMtaarinimedParing clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("kpv");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Kpv))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "kpv")) {
                goto kpv;
            }
            else {
                return;
            }
        kpv:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaarinimed_paring>kpv");
            }
            clazz.Kpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("kpv")).Value;
            goto START;
        }
    }
}
